package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.common.BaseAbility;
import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.axis.Axis;
import cn.limc.ohoscharts.entity.IStickEntity;
import cn.limc.ohoscharts.entity.ListChartData;
import cn.limc.ohoscharts.entity.StickEntity;
import cn.limc.ohoscharts.view.MinusStickChart;
import ohos.aafwk.content.Intent;
import ohos.agp.utils.Color;

import java.util.ArrayList;
import java.util.List;

public class MinusStickChartAbility extends BaseAbility {
  MinusStickChart minusstickchart;

  @Override
  protected void onStart(Intent intent) {
    super.onStart(intent);
    setUIContent(ResourceTable.Layout_ability_minus_stick_chart);
    initMinusStickChart();
  }


//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.minus_stick_chart, menu);
//        return true;
//    }

  private void initMinusStickChart() {
    this.minusstickchart = (MinusStickChart) findComponentById(ResourceTable.Id_minusstickchart);

    List<IStickEntity> data = new ArrayList<IStickEntity>();
    data.add(new StickEntity(50000, 0, 20110603));
    data.add(new StickEntity(42000, 0, 20110703));
    data.add(new StickEntity(32000, 0, 20110803));
    data.add(new StickEntity(21000, 0, 20110903));
    data.add(new StickEntity(0, -12000, 20111003));
    data.add(new StickEntity(0, -28000, 20111103));
    data.add(new StickEntity(0, -41000, 20111203));
    data.add(new StickEntity(0, -25000, 20120103));
    data.add(new StickEntity(0, -18000, 20120203));
    data.add(new StickEntity(14000, 0, 20120303));
    data.add(new StickEntity(24000, 0, 20120303));
    data.add(new StickEntity(36000, 0, 20120303));
    data.add(new StickEntity(46000, 0, 20120303));
    minusstickchart.setStickData(new ListChartData<IStickEntity>(data));

    minusstickchart.setMaxSticksNum(data.size());
    minusstickchart.setMaxValue(50000);
    minusstickchart.setMinValue(-50000);

    minusstickchart.setBorderColor(Color.GRAY.getValue());
    minusstickchart.setAxisXColor(Color.WHITE.getValue());
    minusstickchart.setAxisYColor(Color.WHITE.getValue());
    minusstickchart.setLatitudeFontColor(Color.WHITE.getValue());
    minusstickchart.setLatitudeColor(Color.GRAY.getValue());
    minusstickchart.setLongitudeFontColor(Color.WHITE.getValue());
    minusstickchart.setLongitudeColor(Color.GRAY.getValue());
    // 最大纬线数
    minusstickchart.setLatitudeNum(3);
    // 最大经线数
    minusstickchart.setLongitudeNum(2);
    minusstickchart.setDisplayLongitudeTitle(true);
    minusstickchart.setDisplayLatitudeTitle(true);
    // minusstickchart.setDisplayCrossXOnTouch(false);
    // minusstickchart.setDisplayCrossYOnTouch(false);
    minusstickchart.setDisplayLatitude(true);
    minusstickchart.setDisplayLongitude(true);

    minusstickchart.setDataQuadrantPaddingTop(5);
    minusstickchart.setDataQuadrantPaddingBottom(5);
    minusstickchart.setDataQuadrantPaddingLeft(5);
    minusstickchart.setDataQuadrantPaddingRight(5);
    // minusstickchart.setAxisYTitleQuadrantWidth(50);
    // minusstickchart.setAxisXTitleQuadrantHeight(20);
    minusstickchart.setAxisXPosition(Axis.AXIS_X_POSITION_BOTTOM);
    minusstickchart.setAxisYPosition(Axis.AXIS_Y_POSITION_RIGHT);

  }

}
